﻿
$(document).ready(function () {
//    getProviceAreas(); //获得省级
//    getAreas(); //获得市级
    getSelectUserGrid("ResponsiblePersonName"); //添加用户
});
//添加行政区域 ---开始
function getProviceAreas() {
    $("#ProvinceName").ligerPopupEdit({
        grid: getGridOptions(false, 0),
        valueField: 'AddressAreaID',
        textField: 'AreaName'
    });

}
function getAreas() {
    var pid = -1;
    pid = $.ligerui.get("ProvinceName").getValue();

    var tempgrid = null;
    if (pid == undefined || $.trim(pid) == "") {
        tempgrid = getGridEmptyOptions();
    }
    else {
        tempgrid = getGridOptions(false, 1);
    }
    $("#CityName").ligerPopupEdit({
        grid: tempgrid,
        valueField: 'AddressAreaID',
        textField: 'AreaName'
    });
}
function getGridOptions(checkbox,parentId) {
    var options = {
        columns: [
                        { display: 'Key', name: 'AddressAreaID', type: 'text', hide: 1 },
                        { display: '地区名称', name: 'AreaName', mintWidth: 80, width: 120 },
                        { display: '地区编码', name: 'AreaCode', mintWidth: 80, width: 120 }
                    ], switchPageSizeApplyComboBox: false, 
        parms: { ParentNodeId: parentId },
        url: "../Client/GetAddressAreas" ,
        pageSize: 10,
        checkbox: checkbox
    };
    return options;
}

function getGridEmptyOptions() {
    var options = {
        columns: [
                        { display: 'Key', name: 'AddressAreaID', type: 'text', hide: 1 },
                        { display: '地区名称', name: 'AreaName', mintWidth: 80, width: 120 },
                        { display: '地区编码', name: 'AreaCode', mintWidth: 80, width: 120 }
                    ], switchPageSizeApplyComboBox: false,
        data: [{ AddressAreaID: 0, AreaName: "", AreaCode: ""}],
        pageSize: 10,
        checkbox: false
    };
    return options;
}

//添加行政区域 ---结束


//添加用户列表 --开始
function getSelectUserGrid(controllerId) {
    $("#" + controllerId).ligerPopupEdit({
        grid: getUserGridOptions(false),
        valueField: 'Key',
        textField: 'Name'
    });
}
function getUserGridOptions(checkbox) {
    var options = {
        columns: [
                        { display: 'Key', name: 'Key', type: 'text', hide: 1 },
                        { display: '登陆名', name: 'LoginName', mintWidth: 80, width: 120 }, //, type: 'int', mintWidth: 40, width: 100
                        {display: '姓名', name: 'Name', mintWidth: 80, width: 120 },
                        { display: '性别', name: 'Gender', mintWidth: 60, width: 80 },
                        { display: '出生年月', name: 'Birthday', type: 'selfDate', mintWidth: 100, width: 140 },
                        { display: '移动电话', name: 'Mobile', mintWidth: 80, width: 140 },
                        { display: '固定电话', name: 'Tel', mintWidth: 80, width: 140 },
                        { display: 'QQ', name: 'QQ', mintWidth: 80, width: 120 },
                        { display: '组织机构', name: 'OrgName', mintWidth: 80, width: 120 },
                        { display: '部门', name: 'DeptName', mintWidth: 80, width: 120 },
                        { display: '状态', name: 'IsEnable', mintWidth: 80, width: 120 }
                    ], switchPageSizeApplyComboBox: false,
        url: "../User/GetAllUsers?id=" + Math.random(),
        method: "GET",
        pageSize: 10,
        checkbox: checkbox
    };
    return options;
}
//添加用户列表 --结事

